package com.mediator.smartHouse;

public class Test {
    public static void main(String[] args) {
        //测试类，闹钟响了之后要去需要去一连串的控制 咖啡机 电视 窗帘
        //在这里只要告诉中介，闹钟响了，至于如果控制 咖啡机 电视 窗帘  由中介决定

        //创建中介 抽象中介和抽象同事之间你中有我我中有你
        Mediator mediator = new ConcreteMediator();
        //创建各个对象，交给中介管理
        AlarmColleague alarm =new  AlarmColleague(mediator , "alarm");
        mediator.registerColleague(alarm);
        CoffeeMachineColleague coffee = new CoffeeMachineColleague(mediator , "coffee");
        mediator.registerColleague(coffee);
        TVColleague tv = new TVColleague(mediator , "tv");
        mediator.registerColleague(tv);
        CurtainsColleague curtain = new CurtainsColleague(mediator , "curtain");
        mediator.registerColleague(curtain);

        //现在闹钟响了
        alarm.ring();


    }
}
